#ifndef SDBULLET_H
#define SDBULLET_H

#include <vector>
#include <math.h>
#include "../src/chipmunk.h"
#include "sdObject.h"

class sdTimed : public sdObject {
private:
    cpFloat ttl_; //Ticks to live
	cpFloat maxTtl_;
    bool dying_;
    
public:

    inline sdTimed(cpFloat ttl, cpBody* body) : sdObject(body), ttl_(ttl), maxTtl_(ttl), dying_(false) {}
   
    inline void update(cpFloat ticks) {
        if(ttl_ > 0 && dying_) {
            ttl_ -= ticks;
        }
    }
    
    inline cpFloat getTtl() {return ttl_;}
    inline void setTtl(cpFloat ttl) {
        if(!dying_) {
            ttl_ = ttl;
			maxTtl_ = ttl;
        }
    }

	inline void start() {dying_ = true;}

	inline bool dying() {return dying_;}
	inline cpFloat maxTtl() {return maxTtl_;}
    
    inline bool dead() {return ttl_ < 0.0;}
};

#endif
